package com.geek.framework.study.aquickstart.netflix;

import com.netflix.config.DynamicIntProperty;
import com.netflix.config.DynamicPropertyFactory;


public class DynamicPropertiesDemo {

    static final String TEST_KEY = "myProperties";
    static final int TEST_VALUE = 123;

    public static void main(String[] args) {
//        simpleDynamicDemo();

        DynamicIntProperty intProperty = DynamicPropertyFactory.getInstance()
                .getIntProperty(TEST_KEY, TEST_VALUE);

        Integer oldValue = intProperty.getValue();
        intProperty.addCallback(()->{
            System.out.println("oldValue = " + oldValue);
            System.out.println("newValue = " + intProperty.getValue());
        });

        //想办法修改下属性值并可以发送通知


    }

    private static void simpleDynamicDemo() {
        DynamicIntProperty intProperty = DynamicPropertyFactory.getInstance()
                .getIntProperty(TEST_KEY, TEST_VALUE);
        System.out.println(intProperty.get());
    }
}
